package com.hhxy.demo;

public class Computer {
    private String name;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Computer(String name) {
        this.name = name;
    }
    //电脑开机
    public void run(){
        System.out.println("电脑开机了");
    }
    //鼠标和电脑进行拼接
    public void joint(USB obj){
        //鼠标或者键盘想链接电脑先插入USB
        obj.insert();
        //插入后各自进行各自的功能
        if(obj instanceof Mouse){
            Mouse m = (Mouse) obj;
            m.click();
        }else{
            KeyBoard k = (KeyBoard) obj;
            k.keyDown();

        }
        //鼠标或者电脑不行链接电脑就拔出USB
        obj.putOut();
    }
}
